package com.yy.train.ticket.train.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



import com.yy.train.ticket.train.dao.TtStationDao;
import com.yy.train.ticket.train.entity.TtStationEntity;
import com.yy.train.ticket.train.service.TtStationService;

import javax.annotation.Resource;


@Service("ttStationService")
public class TtStationServiceImpl extends ServiceImpl<TtStationDao, TtStationEntity> implements TtStationService {

@Resource
    TtStationDao ttStationDao;
@Override
public void saveStation(TtStationEntity ttStation){
    Long aLong = this.ttStationDao.selectCount(Wrappers.<TtStationEntity>lambdaQuery().eq(TtStationEntity::getStationName, ttStation.getStationName()));
    try {
        Thread.sleep(300);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    if (aLong==0L){
        this.ttStationDao.insert(ttStation);
    }else {
        System.out.println("已经有添加站点");
    }

}

}